﻿/**
 * ...
 * @author George Mavchun
 */

package gui.hug.priv;

import flash.display.Shape;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.text.TextFormat;
import gui.hug.HUGSprite;
import gui.hug.HUGLabel;
import gui.hug.HUGColors;

class HUGUserButtonWithIconDisplayState extends HUGSprite
{
	private var w : Float;

	public function new(text : String, w : Float, bgColor : Int, ?textFormat : TextFormat) 
	{
		super();
		this.w = w;		
		addImage(text, bgColor, textFormat);
	}

	private function addImage(text : String, bgColor : Int, ?textFormat : TextFormat) {
		var shape = new Shape();
		
		//shape.graphics.lineStyle(1, HUGColors.VK_BORDER_OUTER);
		shape.graphics.beginFill(bgColor);
        shape.graphics.drawRect(0, 0, w, 20);
        shape.graphics.endFill();
		shape.graphics.lineStyle(1, 0x000000);
		
		addChild(shape);
		
		var label : HUGLabel = new HUGLabel();
		label.setLocation(20, 0);
		label.text = text;
		if (null != textFormat) {
			label.setTextFormat(textFormat);
		}
		addChild(label);
		
		var icon : HUGSprite = new HUGSprite();
		icon.setLocation(2, 1);
		icon.addChild(ImageHelper.getUserIcon());
		addChild(icon);
	}
	
}